<template>
  <ElDrawer v-model="visible" size="80%" direction="ttb" :with-header="false">
    <!-- <span>{{purchaseBill}}</span> -->
    <ReadOnlyPurchase :purchase-bill="purchaseBill">
      <template #auditor>
        <span style="color:red">*</span>
        <ElSelect v-model="purchaseBill.auditor">
          <ElOption label="审核者-赵六" value="zhaoliu008"></ElOption>
          <ElOption label="审核者-齐鲁" value="qilu002"></ElOption>
          <ElOption label="测试用-swagger" value="swagger"></ElOption>
        </ElSelect>
      </template>
    </ReadOnlyPurchase>

    <ElDivider></ElDivider>
    <ElButton type="primary" @click="submit()">提交</ElButton>
    <!-- <ReadOnlyPurchase :purchase-bill="purchaseBill">
      <template #auditMsg>
        <ElInput v-model="purchaseBill.auditMsg"></ElInput>
      </template>

      <template #applier="that">
        <ElTag>{{ that.val }} {{ that.abc }}</ElTag>
        等效于
        <ElTag>{{ purchaseBill.applier }}</ElTag>
      </template>
    </ReadOnlyPurchase> -->
  </ElDrawer>
</template>
<script lang="ts">
import { PurchaseBill } from '@/entity/purchase.entity'

/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import from

export default defineComponent({
  name: 'PurchaseSubmit',
  emits: ['postSubmit'],
  props: {
    sampleP: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      sampleD: 'value',
      purchaseBill: {} as PurchaseBill,
      visible: false
    }
  },
  computed: {
    /* sampleC() {
      return this.sampleD + "--";
    }, */
  },
  created() {},
  mounted() {},
  methods: {
    // sampleM() {},
    show(data: PurchaseBill) {
      this.purchaseBill = data
      this.visible = true
    },
    async submit() {
      //   ElMessage.success(JSON.stringify(this.purchaseBill))
      if (!this.purchaseBill.auditor) {
        ElMessage.error('请先确定提交人')
      } else {
        const res = await axios({
          method: 'put',
          url: '/purchase/submit',
          data: this.purchaseBill
        })
        ElMessage.success('提交成功')
        this.$emit('postSubmit', 1)
        this.visible = false
      }
    }
  },
  watch: {
    // sampleP(n, o) {},
  }
})
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
